package com.zzyl.controller;

import com.zzyl.base.PageResponse;
import com.zzyl.base.ResponseResult;
import com.zzyl.dto.NursingPlanDto;
import com.zzyl.service.NursingPlanService;
import com.zzyl.vo.NursingPlanVo;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.apache.ibatis.annotations.Mapper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

import static com.zzyl.base.ResponseResult.success;

@RestController
@RequestMapping("/nursing/plan")
@Api(tags = "护理计划接口")
public class NursingPlanControllre {
    @Autowired
    private NursingPlanService nursingPlanService;

    @GetMapping
    @ApiOperation(value = "查询所有护理计划")
    public ResponseResult<NursingPlanVo> listAll(){
        List<NursingPlanVo> nursingPlanVo = nursingPlanService.listAll();
        return success(nursingPlanVo);
    }

    @PostMapping
    @ApiOperation(value = "新增护理计划")
    public ResponseResult add(@RequestBody NursingPlanDto nursingPlanDto){
        nursingPlanService.add(nursingPlanDto);
        return success();
    }

    @GetMapping("/search")
    @ApiOperation(value = "分页查询护理计划")
    public ResponseResult<PageResponse<NursingPlanVo>> PageNursing(Integer pageNum, Integer pageSize, String name, Integer status){
        return success(nursingPlanService.PageNursing(pageNum,pageSize,name,status));
    }

    @GetMapping("/{id}")
    @ApiOperation(value = "根据id查询护理计划")
    public ResponseResult<NursingPlanVo> getNursing(@PathVariable Long id){
        NursingPlanVo nursingPlanVo = nursingPlanService.getNursing(id);
        return success(nursingPlanVo);
    }

    @PutMapping("/{id}")
    @ApiOperation(value = "修改护理计划")
    public ResponseResult update(@RequestBody NursingPlanDto nursingPlanDto){
        nursingPlanService.update(nursingPlanDto);
        return success();
    }

    @DeleteMapping("/{id}")
    @ApiOperation(value = "删除护理计划")
    public ResponseResult delete(@PathVariable Long id){
        nursingPlanService.delete(id);
        return success();
    }

    @GetMapping("/{id}/status/{status}")
    @ApiOperation(value = "修改护理计划状态")
    public ResponseResult modifyState(@PathVariable Long id,@PathVariable Integer status){
        nursingPlanService.modifyState(id,status);
        return success();
    }
}
